package com.framework.bdf4j.socket.coder;

import java.nio.charset.Charset;
import java.util.List;
import java.util.logging.Logger;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.string.StringDecoder;

public class MyDecoder extends StringDecoder {



    private Charset charset;

    public MyDecoder(Charset charset) {
        this.charset = charset;
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
		StringBuffer sb = new StringBuffer();
        String data = in.toString(charset);
//        System.out.println(data+"<-----");
     
        try {
			   System.out.println("--------"+data);

			if (data != null && data.length() >= 10) {
				data= data.substring(10);//去掉10位长度
            }
			   System.out.println("JIEMA"+data);
            sb.append(data);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        out.add(sb.toString());
    }
}

